package com.example.demo.polyglot;

import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Source;
import org.graalvm.polyglot.Value;

/**
 * @program: native
 * @description: 测试多语言
 * @author: Tan
 * @create: 2023-03-12 16:11
 **/

public class HelloPolyglot {
    static String JS_CODE = "(function myFun(param){console.log('hello '+param);})";
    public static void main(String[] args) {
        System.out.println("Hello Java!");
        String a="javascript";
        try (Context context = Context.create()) {
            Value value = context.eval("js", JS_CODE);
            value.execute(a);
        }
    }
}
